package leetcode_2401_2500;

public class LeeCode_2498 {
    public static void main(String[] args) {
        System.out.println(maxJump(new int[]{0, 3, 9}));
        System.out.println(maxJump(new int[]{0,2,5,6,7}));
    }
    private static int maxJump(int[] stones) {
        int n = stones.length;
        int max = 0;
        int i = 0;
        while (i + 2 < n){
            max = Math.max(max, stones[i + 2] - stones[i]);
            i += 2;
        }
        if (i == n - 2){
            max = Math.max(max, stones[n - 1] - stones[i]);
        }
        i = 1;
        while (i + 2 < n){
            max = Math.max(max, stones[i + 2] - stones[i]);
            i += 2;
        }
        if (i == n - 2){
            max = Math.max(max, stones[n - 1] - stones[i]);
        }
        return max;
    }
}
